package engine.systems.control.motionControl
{
	import engine.classes.enumerations.SystemPriority;
	import engine.systems.update.GameSystem;
	import engine.utils.Mouse;
	
	public class MotionControlSystem extends GameSystem
	{
		public function MotionControlSystem()
		{
			super(MotionControlNode, updateNode, null, nodeRemoved);
			
			this.priority = SystemPriority.UPDATE;
		}
		
		private function updateNode(node:MotionControlNode, time:Number):void
		{
			if(node.control.locked) return;
			
			node.target.locked = !Mouse.isDown();
		}
		
		private function nodeRemoved(node:MotionControlNode):void
		{
			node.target.locked = false;
		}
	}
}